﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace canyinguanlixitong
{
    public partial class frmaddgoods : Form
    {
        public frmaddgoods()
        {
            InitializeComponent();
        }
        string strconn = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void tbxleibie_TextChanged(object sender, EventArgs e)
        {

        }

        private void frmaddgoods_Load(object sender, EventArgs e)
        {

        }
        public void add()
        {
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();
            int bianhao = Convert.ToInt32(this.tbxleibie.Text);
            string lb = this.tbxmingc.Text;
            string sql = @"insert into [Commodity type](SlId,slLei)
                values('" + bianhao + "','"+lb+"')";
            SqlCommand cmd = new SqlCommand(sql, conn);
            int result = cmd.ExecuteNonQuery();
            if (result == 1)
            {
                MessageBox.Show("新增成功");
            }
            else
            {
                MessageBox.Show("新增失败");
            }

            conn.Close();
        }

        private void buttonsave_Click(object sender, EventArgs e)
        {
            add();
        }

        private void buttonquxaio_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
